package com.crm.system.service.impl.orderManager;

import com.crm.common.model.DhPageInfo;
import com.crm.model.entity.orderManager.CustomerOrderGiftRelation;
import com.crm.service.orderManager.CustomerOrderGiftRelationDbService;
import com.crm.system.service.orderManager.CustomerOrderGiftRelationService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @ Author ：pym
 * @ Date   ：2021/3/19 9:19
 */
@Service
public class CustomerOrderGiftRelationServiceImpl implements CustomerOrderGiftRelationService {
    @Autowired
    CustomerOrderGiftRelationDbService customerOrderGiftRelationDbService;

    /**
     * 订单管理-订单列表-订单详情-赠品详情列表
     * @Author pym
     * @Date  2021/3/19 9:27
     * @param pageIndex
     * @param pageSize
     * @param productOrderId
     * @return {@link {com.crm.common.model.DhPageInfo<com.crm.model.entity.orderManager.CustomerOrderGiftRelation>}}
     */
    @Override
    public DhPageInfo<CustomerOrderGiftRelation> selectCustomerOrderGiftRelationList(Integer pageIndex, Integer pageSize, String productOrderId) {

        if (pageIndex != null && pageSize != null) {
            PageHelper.startPage(pageIndex, pageSize);
        }
        List<CustomerOrderGiftRelation> customerOrderGiftRelations = customerOrderGiftRelationDbService.selectCustomerOrderGiftRelationList(productOrderId);
        PageInfo<CustomerOrderGiftRelation> pageInfo = new PageInfo<CustomerOrderGiftRelation>(customerOrderGiftRelations);
        return new DhPageInfo<CustomerOrderGiftRelation>(pageInfo, customerOrderGiftRelations);
    }
}
